package com.yanqu.road.server.manger.activity.springdinner;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.springdinner.BallData;
import com.yanqu.road.entity.activity.springdinner.SpringDinnerBallConfig;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGoodsType;
import com.yanqu.road.entity.enums.eSpringDinnerGameType;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.logic.bussiness.activity.SpringDinnerBusiness;
import com.yanqu.road.pb.activity.SpringDinnerProto;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.springdinner.SpringDinnerModule;
import com.yanqu.road.server.gameplayer.module.player.BagModule;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.config.GoodsBagMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class SpringDinnerMgr extends TempMgr {

    private static RandomHelper randomHelper = new RandomHelper();

    private static ActivityInfo activityInfo;

    private static Map<Integer, SpringDinnerBallConfig> configBallMap = new ConcurrentHashMap<>();

    private static boolean debug = false;

    private static boolean isRedPacketOpen = false;

    private static int recoverTime;//秒
    private static int recoverHp;
    /*不同模式对应的配置：普通场；快速场；极速场*/
    //不同场次消耗的体力
    private static Map<Integer,Integer> gameCostHpMap = new ConcurrentHashMap<>();
    //不同场次的倍率开启条件等
    private static Map<Integer,List<Integer>> gameModeParamMap = new ConcurrentHashMap<>();
    //积分一定步数后加成
    private static Map<Integer,Integer> gameScoreAddMap = new ConcurrentHashMap<>();
    //生成的随机球的范围
    private static Map<Integer,List<Integer>> gameBallInitMap = new ConcurrentHashMap<>();
    //对应的球的对应的权重
    private static Map<Integer,Map<Integer,Integer>> gameBallWeightMap = new ConcurrentHashMap<>();
    //对应排名的球的加成权重
    private static Map<Integer,List<Integer>> gameBallAddWeightMap = new ConcurrentHashMap<>();
    //开启红包需要积分每次增加多少
    private static List<Long> openTableScoreList = new ArrayList<>();
    //红包配置
    private static List<Integer> redPacketParamList = new ArrayList<>();

    //盘面长度
    private static Double xLenth = 750D;
    //盘面宽度
    private static Double yLenth = 980D;

    private static int SPRING_DINNER_SCORE_ITEM_ID = 101994;//积分道具

    private static int SPRING_DINNER_POWER_RECOVER_ITEM_ID = 120700;

    private static int SPRING_DINNER_DELETE_ITEM_ID = 120701;

    private static int SPRING_DINNER_POWER_MAX_NUM = 60;

    private static String SPRING_DINNER_POWER_RECOVER_TIME = "600;1";

    private static String SPRING_DINNER_COST_ENERGY_PARAM = "1|8|16";
    //普通场；快速场；极速场参数（倍数，开启积分，开启vip
    private static String SPRING_DINNER_MULTIPLE_MODE_PARAM = "1;0;-1|4;3000;-1|16;-1;6";
    //积分加成（数量；加成值千分比【0~10，积分×1|11~20，积分×1.1】
    private static String SPRING_DINNER_SCORE_ADD_PRAM = "10;1000|20;1100|30;1200|50;1300|100000;1300";

    private static String SPRING_DINNER_FOOD_INIT_PARAM_1 = "1001|1001|1001|1002|1003";
    private static String SPRING_DINNER_FOOD_BASE_PARAM_1 = "1001;20|1002;20|1003;20|1004;20|1005;20";
    private static String SPRING_DINNER_FOOD_ADD_PARAM_1 = "45|25|15|10|5";

    private static String SPRING_DINNER_FOOD_INIT_PARAM_2 = "2001|2001|2001|2002|2003";
    private static String SPRING_DINNER_FOOD_BASE_PARAM_2 = "2001;20|2002;20|2003;20|2004;20|2005;20";
    private static String SPRING_DINNER_FOOD_ADD_PARAM_2 = "45|25|15|10|5";

    private static String SPRING_DINNER_FOOD_INIT_PARAM_3 = "3001|3001|3001|3002|3003";
    private static String SPRING_DINNER_FOOD_BASE_PARAM_3 = "3001;20|3002;20|3003;20|3004;20|3005;20";
    private static String SPRING_DINNER_FOOD_ADD_PARAM_3 = "45|25|15|10|5";


    //年夜饭开启条件（第1场积分|第2场积分|第3场积分
    private static String SPRING_DINNER_OPEN_LIMIT = "500|1000|2000|3000|4000|5000|6000|7000|8000|9000|10000|11000|12000|13000|14000|15000|16000|17000|18000|19000|20000|21000|22000|23000|24000|25000|26000|27000|28000|29000|30000|31000|32000|33000|34000|35000|36000|37000|38000|39000|40000";
    //红包参数（发红包上限数量|抢红包上限数量|发红包文本字符|抢红包文本字符|单个红包元宝数|单个红包人数|单个红包保底元宝数）
    private static String SPRING_DINNER_RED_BAG_PARAM = "5|1|12|12|50|5|1|500|1500";

    // 过期提醒邮件的时间(分钟，活动开始时间为0)
    private static int MEITUAN_DINNER_OVERDUE_MAIL = 0;

    // 每次分享及时获取体力数
    private static String MEITUAN_DINNER_SHARE_ENERGY_NUM;

    // 每日分享次数上限
    private static int MEITUAN_DINNER_SHARE_MAX_NUM;

    //每次入场消耗的体力数
    private static int MEITUAN_DINNER_ENERGY_COST;

    public static int getMeituanDinnerEnergyCost() {
        return MEITUAN_DINNER_ENERGY_COST;
    }

    public static String getShareEnergyNum() {
        return MEITUAN_DINNER_SHARE_ENERGY_NUM;
    }

    public static int getShareMaxNum() {
        return MEITUAN_DINNER_SHARE_MAX_NUM;
    }

    public static boolean isDebug(){
        return debug;
    }

    public static boolean isRedPacketOpen(){
        return isRedPacketOpen;
    }

    public static Double getxLenth(){
        return xLenth;
    }

    public static Double getyLenth(){
        return yLenth;
    }

    public static int getScoreItemId(){
        return SPRING_DINNER_SCORE_ITEM_ID;
    }
    public static int getRecoverItemId(){
        return SPRING_DINNER_POWER_RECOVER_ITEM_ID;
    }
    public static int getGameClearItemId(){
        return SPRING_DINNER_DELETE_ITEM_ID;
    }
    public static int getMaxHp(){
        return SPRING_DINNER_POWER_MAX_NUM;
    }
    public static int getRecoverHpTime(){
        return recoverTime;
    }
    public static int getRecoverHp(){
        return recoverHp;
    }
    public static int getCostHp(int type){
        return gameCostHpMap.get(type);
    }
    public static int getPlayModeScoreMul(int type){
        return gameModeParamMap.get(type).get(0);
    }
    public static int getPlayModeScoreLimit(int type){
        return gameModeParamMap.get(type).get(1);
    }
    public static int getPlayModeVipLimit(int type){
        return gameModeParamMap.get(type).get(2);
    }
    //获得加成千分比
    public static int getStepScoreAdd(int step){
        int addStep = 0;
        int addValue = 0;
        for(int configStep : gameScoreAddMap.keySet()){
            if(step > configStep && addStep <= configStep){
                addStep = configStep;
                addValue = gameScoreAddMap.get(configStep);
            }
        }
        return addValue;
    }

    //随机一个球，随机规则是球的权重加上加成权重，加成权重按照场上对应球的个数和球id排序最大的获得对应的加成
    private static int randomBallId(int type,Map<Integer,Integer> ballCountMap){
        Map<Integer,Integer> ballWeightMap = gameBallWeightMap.get(type);
        List<Integer> ballAddWeightList = gameBallAddWeightMap.get(type);
        Map<Integer,Integer> weightMap = new ConcurrentHashMap<>();
        List<Integer> ballIdList = new ArrayList<>(ballCountMap.keySet());
        List<Integer> countList = new ArrayList<>(ballCountMap.values());
        Collections.sort(ballIdList);
        Collections.sort(countList);
        Collections.reverse(countList);
        for(int i = 0; i < countList.size(); i++){
            int count = countList.get(i);
            for(int j = 0; j < ballIdList.size();j++){
                int ballId = ballIdList.get(j);
                if(ballCountMap.get(ballId) == count && !weightMap.containsKey(ballId)){
                    weightMap.put(ballId,ballWeightMap.get(ballId) + ballAddWeightList.get(i));
                    break;
                }
            }
        }
        int totalWeight = 0;
        for (Integer weight : weightMap.values()) {
            totalWeight += weight;
        }
        int randomNum = randomHelper.next(0, totalWeight);
        for (Integer ballId : weightMap.keySet()) {
            int value = weightMap.get(ballId);
            if (randomNum < value) {
                return ballId;
            }
            randomNum -= value;
        }
        return 0;
    }

    private static int makeBallId(int type,int step,Map<Integer,BallData> ballMap){
        int newBallId = 0;
        //前几个固定
        if(step <= gameBallInitMap.get(type).size()){
            newBallId = gameBallInitMap.get(type).get(step-1);
        }
        if(newBallId == 0){
            Map<Integer,Integer> ballCountMap = new ConcurrentHashMap<>();
            for(Integer ballId : gameBallWeightMap.get(type).keySet()){
                ballCountMap.put(ballId,0);
            }
            for(BallData ball : ballMap.values()){
                if(ballCountMap.containsKey(ball.getBallId())){
                    ballCountMap.put(ball.getBallId(),ballCountMap.get(ball.getBallId()) + 1);
                }
            }
            newBallId = randomBallId(type,ballCountMap);
        }
        return newBallId;
    }

    public static BallData getNextBall(int type,int step,int no ,Map<Integer,BallData> gameBallMap){
        int newBallId = makeBallId(type,step,gameBallMap);
        SpringDinnerBallConfig nextBallConfig = configBallMap.get(newBallId);
        BallData nextBall = new BallData();
        nextBall.setNo(no);
        nextBall.setStep(step);
        nextBall.setBallId(nextBallConfig.getId());
        return nextBall;
    }


    public static SpringDinnerBallConfig getBallConfigById(int ballId){
        return configBallMap.get(ballId);
    }

    public static List<Integer> getLast3BallId(int type){
        List<Integer> resList = new ArrayList<>();
        Map<Integer,SpringDinnerBallConfig> typeMap = new ConcurrentHashMap<>();
        for(SpringDinnerBallConfig ballConfig : configBallMap.values()){
            if(ballConfig.getType() == type){
                typeMap.put(ballConfig.getId(),ballConfig);
            }
        }
        List<Integer> ballIdList = new ArrayList<>(typeMap.keySet());
        Collections.sort(ballIdList);
        for(int i = ballIdList.size() - 3;i < ballIdList.size();i++){
            resList.add(ballIdList.get(i));
        }
        return resList;
    }

    public static SpringDinnerProto.SpringDinnerConfigDataTemp.Builder getConfigDataTempBuilder(String language) {
        SpringDinnerProto.SpringDinnerConfigDataTemp.Builder builder = SpringDinnerProto.SpringDinnerConfigDataTemp.newBuilder();
        for(SpringDinnerBallConfig ballConfig : configBallMap.values()){
            SpringDinnerProto.BallConfigTemp.Builder npcBuilder = SpringDinnerProto.BallConfigTemp.newBuilder();
            npcBuilder.setId(ballConfig.getId());
            npcBuilder.setName(ServerLanguageMgr.getContent(ballConfig.getName(), language));
            npcBuilder.setDesc(ServerLanguageMgr.getContent(ballConfig.getDesc(), language));
            npcBuilder.setType(ballConfig.getType());
            npcBuilder.setQuality(ballConfig.getQuality());
            npcBuilder.setPic(ballConfig.getPic());
            npcBuilder.setIcon(ballConfig.getIcon());
            npcBuilder.setWeight(ballConfig.getWeight());
            npcBuilder.setWidth(ballConfig.getWidth());
            npcBuilder.setScore((int)ballConfig.getScore());
            builder.addBall(npcBuilder);
        }
        return builder;
    }

    //两个球合成下一个球
    public static int getComposeBallConfig(int ballId) {
        SpringDinnerBallConfig ballConfig = configBallMap.get(ballId);
        if(configBallMap.containsKey(ballId + 1)){
            SpringDinnerBallConfig composeBallConfig = configBallMap.get(ballId);
            if(composeBallConfig.getType() == ballConfig.getType()){
                return ballId + 1;
            }
        }
        int composeBallId = Integer.MAX_VALUE;
        for(SpringDinnerBallConfig ball : configBallMap.values()){
            if(ball.getType() == ballConfig.getType()){
                if(ball.getId() > ballId && composeBallId > ball.getId()){
                    composeBallId = ball.getId();
                }
            }
        }
        return composeBallId;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static void reloadActivityData() {
        getLogger().info("reload springdinner activity start");

        // 获取活动
        ActivityInfo tmpActivityInfo;
        List<ActivityInfo> openActivityInfoList = NormalActivityMgr.getOpenActivityInfoList(eActivityType.SpringDinner.getValue());
        if (openActivityInfoList.size() <= 0) {
            //活动移除内存
            gameCostHpMap.clear();
            gameModeParamMap.clear();
            gameScoreAddMap.clear();
            gameBallInitMap.clear();
            gameBallWeightMap.clear();
            gameBallAddWeightMap.clear();
            openTableScoreList.clear();
            redPacketParamList.clear();
            configBallMap.clear();
            activityInfo = null;

            getLogger().info("no springdinner activity in show time");
            return;
        }
        tmpActivityInfo = openActivityInfoList.get(0);

        Map<Integer, SpringDinnerBallConfig> tempBallMap = SpringDinnerBusiness.getBallMap(tmpActivityInfo.getActivityId());
        // 活动配置
        Map<String, ActivityConfig> activityConfigMap = NormalActivityMgr.getActivityConfigMap(tmpActivityInfo.getActivityId());
        if(activityConfigMap != null){
            if(activityConfigMap.containsKey("SPRING_DINNER_SCORE_ITEM_ID")){
                SPRING_DINNER_SCORE_ITEM_ID = activityConfigMap.get("SPRING_DINNER_SCORE_ITEM_ID").getIntValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_POWER_RECOVER_ITEM_ID")){
                SPRING_DINNER_POWER_RECOVER_ITEM_ID = activityConfigMap.get("SPRING_DINNER_POWER_RECOVER_ITEM_ID").getIntValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_DELETE_ITEM_ID")){
                SPRING_DINNER_DELETE_ITEM_ID = activityConfigMap.get("SPRING_DINNER_DELETE_ITEM_ID").getIntValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_POWER_MAX_NUM")){
                SPRING_DINNER_POWER_MAX_NUM = activityConfigMap.get("SPRING_DINNER_POWER_MAX_NUM").getIntValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_POWER_RECOVER_TIME")){
                SPRING_DINNER_POWER_RECOVER_TIME = activityConfigMap.get("SPRING_DINNER_POWER_RECOVER_TIME").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_COST_ENERGY_PARAM")){
                SPRING_DINNER_COST_ENERGY_PARAM = activityConfigMap.get("SPRING_DINNER_COST_ENERGY_PARAM").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_MULTIPLE_MODE_PARAM")){
                SPRING_DINNER_MULTIPLE_MODE_PARAM = activityConfigMap.get("SPRING_DINNER_MULTIPLE_MODE_PARAM").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_SCORE_ADD_PRAM")){
                SPRING_DINNER_SCORE_ADD_PRAM = activityConfigMap.get("SPRING_DINNER_SCORE_ADD_PRAM").getValue();
            }

            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_INIT_PARAM_1")){
                SPRING_DINNER_FOOD_INIT_PARAM_1 = activityConfigMap.get("SPRING_DINNER_FOOD_INIT_PARAM_1").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_BASE_PARAM_1")){
                SPRING_DINNER_FOOD_BASE_PARAM_1 = activityConfigMap.get("SPRING_DINNER_FOOD_BASE_PARAM_1").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_ADD_PARAM_1")){
                SPRING_DINNER_FOOD_ADD_PARAM_1 = activityConfigMap.get("SPRING_DINNER_FOOD_ADD_PARAM_1").getValue();
            }

            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_INIT_PARAM_2")){
                SPRING_DINNER_FOOD_INIT_PARAM_2 = activityConfigMap.get("SPRING_DINNER_FOOD_INIT_PARAM_2").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_BASE_PARAM_2")){
                SPRING_DINNER_FOOD_BASE_PARAM_2 = activityConfigMap.get("SPRING_DINNER_FOOD_BASE_PARAM_2").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_ADD_PARAM_2")){
                SPRING_DINNER_FOOD_ADD_PARAM_2 = activityConfigMap.get("SPRING_DINNER_FOOD_ADD_PARAM_2").getValue();
            }

            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_INIT_PARAM_3")){
                SPRING_DINNER_FOOD_INIT_PARAM_3 = activityConfigMap.get("SPRING_DINNER_FOOD_INIT_PARAM_3").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_BASE_PARAM_3")){
                SPRING_DINNER_FOOD_BASE_PARAM_3 = activityConfigMap.get("SPRING_DINNER_FOOD_BASE_PARAM_3").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_FOOD_ADD_PARAM_3")){
                SPRING_DINNER_FOOD_ADD_PARAM_3 = activityConfigMap.get("SPRING_DINNER_FOOD_ADD_PARAM_3").getValue();
            }


            if(activityConfigMap.containsKey("SPRING_DINNER_OPEN_LIMIT")){
                SPRING_DINNER_OPEN_LIMIT = activityConfigMap.get("SPRING_DINNER_OPEN_LIMIT").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_RED_BAG_PARAM")){
                SPRING_DINNER_RED_BAG_PARAM = activityConfigMap.get("SPRING_DINNER_RED_BAG_PARAM").getValue();
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_DEBUG")){
                debug = (activityConfigMap.get("SPRING_DINNER_DEBUG").getIntValue() == 1);
            }
            if(activityConfigMap.containsKey("SPRING_DINNER_RED_PACKET_OPEN")){
                isRedPacketOpen = (activityConfigMap.get("SPRING_DINNER_RED_PACKET_OPEN").getIntValue() == 1);
            }
            if(activityConfigMap.containsKey("MEITUAN_DINNER_OVERDUE_MAIL")){
                MEITUAN_DINNER_OVERDUE_MAIL = activityConfigMap.get("MEITUAN_DINNER_OVERDUE_MAIL").getIntValue();
            }
            if(activityConfigMap.containsKey("MEITUAN_DINNER_SHARE_ENERGY_NUM")){
                MEITUAN_DINNER_SHARE_ENERGY_NUM = activityConfigMap.get("MEITUAN_DINNER_SHARE_ENERGY_NUM").getValue();
            }
            if(activityConfigMap.containsKey("MEITUAN_DINNER_SHARE_MAX_NUM")){
                MEITUAN_DINNER_SHARE_MAX_NUM = activityConfigMap.get("MEITUAN_DINNER_SHARE_MAX_NUM").getIntValue();
            }
            if(activityConfigMap.containsKey("MEITUAN_DINNER_ENERGY_COST")){
                MEITUAN_DINNER_ENERGY_COST = activityConfigMap.get("MEITUAN_DINNER_ENERGY_COST").getIntValue();
            }
        }
        initConfig(tempBallMap,tmpActivityInfo);
        reloadPlayerData();
        getLogger().info("reload springdinner activity end");
    }

    private static void initConfig(Map<Integer, SpringDinnerBallConfig> tempBallMap, ActivityInfo tmpActivityInfo) {
        int tempRecoverTime;//秒
        int tempRecoverHp;
        Map<Integer,Integer> tempGameCostHpMap = new ConcurrentHashMap<>();
        Map<Integer,List<Integer>> tempGameModeParamMap = new ConcurrentHashMap<>();
        Map<Integer,Integer> tempGameScoreAddMap = new ConcurrentHashMap<>();
        Map<Integer,List<Integer>> tempGameBallInitMap = new ConcurrentHashMap<>();
        Map<Integer,Map<Integer,Integer>> tempGameBallWeightMap = new ConcurrentHashMap<>();
        Map<Integer,List<Integer>> tempGameBallAddWeightMap = new ConcurrentHashMap<>();
        List<Long> tempOpenTableScoreList = new ArrayList<>();
        List<Integer> tempRedPacketParamList = new ArrayList<>();

        List<Integer> tempIntegerList;
        List<String> tempStrList;
        tempIntegerList = StringUtils.stringToIntegerList(SPRING_DINNER_POWER_RECOVER_TIME,";");
        tempRecoverTime = tempIntegerList.get(0);
        tempRecoverHp = tempIntegerList.get(1);

        tempIntegerList = StringUtils.stringToIntegerList(SPRING_DINNER_COST_ENERGY_PARAM,"\\|");
        tempGameCostHpMap.put(eSpringDinnerGameType.Normal.getValue(),tempIntegerList.get(0));
        tempGameCostHpMap.put(eSpringDinnerGameType.Quick.getValue(),tempIntegerList.get(1));
        tempGameCostHpMap.put(eSpringDinnerGameType.Fast.getValue(),tempIntegerList.get(2));

        tempStrList = StringUtils.stringToStringList(SPRING_DINNER_MULTIPLE_MODE_PARAM,"\\|");
        tempGameModeParamMap.put(eSpringDinnerGameType.Normal.getValue(),StringUtils.stringToIntegerList(tempStrList.get(0),";"));
        tempGameModeParamMap.put(eSpringDinnerGameType.Quick.getValue(),StringUtils.stringToIntegerList(tempStrList.get(1),";"));
        tempGameModeParamMap.put(eSpringDinnerGameType.Fast.getValue(),StringUtils.stringToIntegerList(tempStrList.get(2),";"));

        tempStrList = StringUtils.stringToStringList(SPRING_DINNER_SCORE_ADD_PRAM,"\\|");
        int startStep = 0;
        for(String tempStr : tempStrList){
            tempIntegerList = StringUtils.stringToIntegerList(tempStr,";");
            tempGameScoreAddMap.put(startStep,tempIntegerList.get(1));
            startStep = tempIntegerList.get(0);
        }

        tempGameBallInitMap.put(eSpringDinnerGameType.Normal.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_INIT_PARAM_1,"\\|"));
        tempGameBallInitMap.put(eSpringDinnerGameType.Quick.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_INIT_PARAM_2,"\\|"));
        tempGameBallInitMap.put(eSpringDinnerGameType.Fast.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_INIT_PARAM_3,"\\|"));

        tempStrList = StringUtils.stringToStringList(SPRING_DINNER_FOOD_BASE_PARAM_1,"\\|");
        Map<Integer,Integer> tempMap = new ConcurrentHashMap<>();
        for(String tempStr : tempStrList){
            tempIntegerList = StringUtils.stringToIntegerList(tempStr,";");
            tempMap.put(tempIntegerList.get(0),tempIntegerList.get(1));
        }
        tempGameBallWeightMap.put(eSpringDinnerGameType.Normal.getValue(),tempMap);
        tempStrList = StringUtils.stringToStringList(SPRING_DINNER_FOOD_BASE_PARAM_2,"\\|");
        tempMap = new ConcurrentHashMap<>();
        for(String tempStr : tempStrList){
            tempIntegerList = StringUtils.stringToIntegerList(tempStr,";");
            tempMap.put(tempIntegerList.get(0),tempIntegerList.get(1));
        }
        tempGameBallWeightMap.put(eSpringDinnerGameType.Quick.getValue(),tempMap);
        tempStrList = StringUtils.stringToStringList(SPRING_DINNER_FOOD_BASE_PARAM_3,"\\|");
        tempMap = new ConcurrentHashMap<>();
        for(String tempStr : tempStrList){
            tempIntegerList = StringUtils.stringToIntegerList(tempStr,";");
            tempMap.put(tempIntegerList.get(0),tempIntegerList.get(1));
        }
        tempGameBallWeightMap.put(eSpringDinnerGameType.Fast.getValue(),tempMap);

        tempGameBallAddWeightMap.put(eSpringDinnerGameType.Normal.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_ADD_PARAM_1,"\\|"));
        tempGameBallAddWeightMap.put(eSpringDinnerGameType.Quick.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_ADD_PARAM_2,"\\|"));
        tempGameBallAddWeightMap.put(eSpringDinnerGameType.Fast.getValue(),StringUtils.stringToIntegerList(SPRING_DINNER_FOOD_ADD_PARAM_3,"\\|"));


        tempOpenTableScoreList = StringUtils.stringToLongList(SPRING_DINNER_OPEN_LIMIT,"\\|");
        tempRedPacketParamList = StringUtils.stringToIntegerList(SPRING_DINNER_RED_BAG_PARAM,"\\|");


        recoverTime = tempRecoverTime;
        recoverHp = tempRecoverHp;
        gameCostHpMap = tempGameCostHpMap;
        gameModeParamMap = tempGameModeParamMap;
        gameScoreAddMap = tempGameScoreAddMap;
        gameBallInitMap = tempGameBallInitMap;
        gameBallWeightMap = tempGameBallWeightMap;
        gameBallAddWeightMap = tempGameBallAddWeightMap;
        openTableScoreList = tempOpenTableScoreList;
        redPacketParamList = tempRedPacketParamList;

        configBallMap = tempBallMap;
        activityInfo = tmpActivityInfo;
    }

    private static void reloadPlayerData() {
        if (ActivityMgr.activityInShowTime(activityInfo)) {
            for (GamePlayer player : GamePlayerMgr.getCopyPlayerMap().values()) {
                if (SystemOpenMgr.systemOpen(player, eSystemId.SpringDinner.getValue())) {
                    SpringDinnerModule module = player.getModule(SpringDinnerModule.class);
                    module.initUserData(activityInfo.getActivityId());
                    module.syncConfigData();
                    module.syncUserData();
                }
            }
        }
    }

    /**
     * 是否在清空道具时间内
     */
    public static boolean isActivityInClearTime() {
        return ActivityMgr.activityInRewardPeriod(activityInfo);
    }

    /**
     * 获取展示中的活动ID（0表示没活动）
     */
    public static int getShowTimeActivityId() {
        if (activityInfo == null) {
            return 0;
        }
        if (activityInShowTime()) {
            return activityInfo.getActivityId();
        }
        return 0;
    }

    public static boolean activityInTime(){
        return ActivityMgr.activityInTime(activityInfo);
    }

    public static boolean activityInShowTime(){
        return ActivityMgr.activityInShowTime(activityInfo);
    }

    public static ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public static int getMeituanDinnerOverdueMail() {
        return MEITUAN_DINNER_OVERDUE_MAIL;
    }

    /**
     * 通知定时任务
     */
    public static void noticeMeiTuanTask() {
        // 判断是否在活动时间内
        if (!activityInShowTime()) {
            return;
        }
        // 只有美团的活动才检测
        if (activityInfo.getChildType() != 2) {
            return;
        }
        // 判断下有没有到达提醒时间
        long now = System.currentTimeMillis();
        if (now < activityInfo.getBeginTime() + getMeituanDinnerOverdueMail() * 60 * 1000) {
            return;
        }
        for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
            player.getModule(SpringDinnerModule.class).noticeMeiTuan();
        }
    }

}
